/*
 * @Author       : jiangxiaoying
 * @Date         : 2020-11-12 17:47:41
 * @LastEditors  : 陈韵同
 * @LastEditTime : 2021-04-08 20:02:15
 * @FilePath     : e:\协同云组件库\1.1.1\vue.config.js
 */
const webpack = require('webpack');
const devServer = require('./config/devServer.js');
const alias = require('./config/alias.js');
const themeSetting = require('./config/antdv/theme');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;

module.exports = {
    // 基本路径
    // baseUrl: '/',
    lintOnSave: false,
    productionSourceMap: false,
    // 输出文件目录
    outputDir: 'dist',
    pages: {
        index: {
            entry: 'src/main.js',
            template: 'public/index.html',
            filename: 'index.html'
        }
    },
    // transpileDependencies:['@vue','@vue/web-component-wrapper'],
    devServer: devServer,
    configureWebpack: {
        output: {
            // libraryExport: 'default', // 该配置会默认只输出export default的内容
            libraryTarget: 'umd'
        },
        plugins: [
            new webpack.ContextReplacementPlugin(/moment[/\\]locale$/, /zh-cn|en/),
            // new BundleAnalyzerPlugin()
        ],
        resolve: {
            alias: alias
        },
        externals: {
            // 'moment': 'moment',
            // '@ant-design/icons/lib/dist': '@ant-design/icons/lib/dist',
            // 'ant-design-vue': 'ant-design-vue',
        },
        // module: {
        //     noParse: /moment.js/
        // }
    },
    css: {
        extract: false,
        // sourceMap: true,
        loaderOptions: {
            less: {
                lessOptions: {
                    modifyVars: themeSetting,
                    javascriptEnabled: true,
                    math: 'always'   // 此处指定为兼容 less-loader 3.x 的默认选项
                }
            },
        },
    },
    chainWebpack: config => {
        // 小于10kb将会被打包成 base64
        config.module
            .rule('images')
            .use('url-loader')
            .loader('url-loader')
            .tap(options => Object.assign(options, { limit: 10240, esModule: false }))
    },
    transpileDependencies: ["cloud-common","cloud-components", "ant-design-vue"],
}